/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.timesoft.zk.common.generator;

import java.util.Random;
import org.apache.log4j.Logger;

/**
 *
 * @author sorasaks
 */
public class RandomStringGenerator {
    
    private static final Logger LOG = Logger.getLogger(RandomStringGenerator.class);
    
    private final Integer length;
    
    public RandomStringGenerator(int length) {
        this.length = length;
    }
    
    public String getRandomString() {
        char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            char c = chars[random.nextInt(chars.length)];
            sb.append(c);
        }
        LOG.debug("::::::::::::::: sb.toString() :::::::::::::::" + sb.toString());
        return sb.toString();
    }
}
